cjpeg compresses the named image file, or the standard input if no file is named, and produces a JPEG/JFIF file on the standard output. The currently supported image file formats are: PPM (PBMPLUS color format), PGM (PBMPLUS gray-scale format), GIF, Targa, and RLE (Utah Raster Toolkit format). (RLE is supported only if the URT library is available.)
The -Q switch lets you trade off compressed file size against quality of the reconstructed image: the higher the -Q setting, the larger the JPEG file, and the closer the output image will be to the original input. Normally you want to use the lowest -Q setting (smallest file) that decompresses into something visually indistinguishable from the original image. For this purpose the -Q setting should be between 50 and 95; the default of 75 is often about right. If you see defects at -Q 75, then go up 5 or 10 counts at a time until you are happy with the output image. (The optimal setting will vary from one image to another.)
-Q 100 will generate a quantization table of all 1's, eliminating loss in the quantization step (but there is still information loss in subsampling, as well as roundoff error). This setting is mainly of interest for experimental purposes. -Q values above about 95 are not recommended for normal use; the compressed file size goes up dramatically for hardly any gain in output image quality.
In the other direction, -Q values below 50 will produce very small files of low image quality. Settings around 5 to 10 might be useful in preparing an index of a large image library, for example. Try -Q 2 (or so) for some amusing Cubist effects. (Note: -Q values below about 25 generate 2-byte quantization tables, which are considered optional in the JPEG standard. cjpeg emits a warning message when you give such a -Q value, because some commercial JPEG programs may be unable to decode the resulting file.)
This example compresses the PPM file foo.ppm with a quality factor of 60 and saves the output as foo.jpg:
Not all variants of Targa file format are supported.
The -T switch is not a bug, it's a feature. (It would be a bug if the Targa format designers had not been clueless.)
Not as fast as we'd like.